package org.hongqi.common.senpec.base.mybatisplus;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hongqi.common.senpec.sys.user.User;

import java.io.ObjectInputFilter;
import java.io.Serializable;
import java.time.LocalDateTime;


@EqualsAndHashCode(callSuper = true)
@MappedSuperclass
@Data
@NoArgsConstructor
@AllArgsConstructor
public class IBaseEntity<T extends Model<?>> extends Model<T> implements Serializable, ObjectInputFilter {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    private Long creator;

    @TableField(fill = FieldFill.INSERT)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDateTime createTime;

    @Transient
    @TableField(exist = false)
    private User creatorObj;

    private Long updater;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDateTime updateTime;

    @Transient
    @TableField(exist = false)
    private User updaterObj;

    @TableLogic
    @Column(name = "deleted", nullable = false, columnDefinition = "smallint default 0")
    private Boolean deleted = false;

    @Transient
    @TableField(exist = false)
    private Long current = 0L;

    @Transient
    @TableField(exist = false)
    private Long size = 20L;

    @Override
    public Status checkInput(FilterInfo filterInfo) {
        return Status.ALLOWED;
    }


/*

      @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 *     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 *     private LocalDateTime invalidDateTime;
 *
 *     @JsonFormat(pattern = "yyyy-MM-dd")
 *     @DateTimeFormat(pattern = "yyyy-MM-dd")
 *     private LocalDate invalidDate;


         <!-- <hq-col>
          <el-form-item label="过期时间：" prop="invalidDateTime">
            <el-date-picker
              v-model="menu.invalidDateTime"
              type="datetime"
              format="YYYY-MM-DD HH:mm:ss"
              value-format="YYYY-MM-DD HH:mm:ss"
            />
          </el-form-item>
        </hq-col>
        <hq-col>
          <el-form-item label="过期日期：" prop="invalidDate">
            <el-date-picker
              v-model="menu.invalidDate"
              type="date"
              format="YYYY-MM-DD"
              value-format="YYYY-MM-DD"
            />
          </el-form-item>
        </hq-col> -->

 */


}
